package com.gxa.common;

import lombok.Data;

//通用响应结果类
@Data
public class Result<T> {
    //响应码
    private Integer code;
    
    // 响应消息
    private String message;
    
    // 响应数据
    private T data;

    //成功响应
    public static <T> Result<T> success() {
        return success(null);
    }

    // 成功响应

    public static <T> Result<T> success(T data) {
        Result<T> result = new Result<>();
        result.setCode(200);
        result.setMessage("操作成功");
        result.setData(data);
        return result;
    }
    
    //失败响应
    public static <T> Result<T> error(String message) {
        Result<T> result = new Result<>();
        result.setCode(500);
        result.setMessage(message);
        return result;
    }
    
    //失败响应
    public static <T> Result<T> error(Integer code, String message) {
        Result<T> result = new Result<>();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }
} 